package com.xiaozheng.service.impl;

import com.xiaozheng.dao.AccountDao;
import com.xiaozheng.service.AccountService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Package: com.xiaozheng.coupling.service.impl
 * @ClassName: AccountServiceImpl
 * @Author: 小政同学    QQ:xiaozheng666888@qq.com
 * @CreateTime: 2020/9/19 18:10
 * @What_is_this_file_for: 业务层实现类
 * @Description: 描述
 * 之前的XML配置：
 * <bean id="accountService" class="com.xiaozheng.service.impl.AccountServiceImpl"
 *      scope="prototype" init-method="init" destroy-method="destroy">
 *      <property name = "" value = ""/ref = ""></property>
 * </bean>
 */
//不写value属性值，默认为当前类名首字母小写
@Component
public class AccountServiceImpl implements AccountService {


    /*@Autowired
    @Qualifier("testAccountDaoImpl")//指定bean的id*/
    @Resource(name = "accountDaoImpl")
    private AccountDao dao;
    //@Autowired
    //private AccountDao testAccountDaoImpl = null;
    //@Autowired
    //private AccountDao accountDaoImpl = null;

    public AccountServiceImpl(){
        System.out.println("对象创建了！！");
    }
    /**
     * 模拟保存账户
     */
    @Override
    public void saveAccountService() {
        //testAccountDaoImpl.saveAccountService();
        //accountDaoImpl.saveAccountService();
        dao.saveAccountService();
        System.out.println("Service中的saveAccountService方法执行");
    }

    public void init() {
        System.out.println("Service中的saveAccountService方法创建");
    }

    public void destroy() {
        System.out.println("Service中的saveAccountService方法销毁");
    }
}
